<?php
$link = mysqli_connect("localhost", "root", "", "test");
echo "aqui " . mysqli_connect_errno();
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* disable autocommit */
mysqli_autocommit($link, FALSE);

mysqli_query($link, "CREATE TABLE myCity LIKE City");
mysqli_query($link, "ALTER TABLE myCity Type=InnoDB");
mysqli_query($link, "INSERT INTO myCity SELECT * FROM City LIMIT 50");

/* commit insert */
mysqli_commit($link);

// delete all rows
if($afetado = mysqli_query($link, "DELETE FROM myCity")){
	echo "var " . $afetado;
	$row = mysqli_fetch_row($afetado);
	echo $row[0] . " - delete <br>";
}


if ($result = mysqli_query($link, "SELECT COUNT(*) FROM myCity")) {
    $row = mysqli_fetch_row($result);
    printf("%d rows in table myCity.\n", $row[0]);
    // Free result
    mysqli_free_result($result);
}

// Rollback
mysqli_rollback($link);
/*
if ($result = mysqli_query($link, "SELECT COUNT(*) FROM myCity")) {
    $row = mysqli_fetch_row($result);
    printf("%d rows in table myCity (after rollback).\n", $row[0]);
    // Free result
    mysqli_free_result($result);
}

// Drop table myCity
mysqli_query($link, "DROP TABLE myCity");
*/
mysqli_close($link);
?>